#!/bin/bash

set -e

cd /tmp
curl -o apache-maven-3.8.8-bin.tar.gz https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
tar -xvf apache-maven-3.8.8-bin.tar.gz
mv apache-maven-3.8.8 /usr/local/bin/maven
rm -rf apache-maven-3.8.8-bin.tar.gz

echo "export PATH=\$PATH:/usr/local/maven/bin" >> ~/.zshrc
source ~/.zshrc

docker() {
  MAVEN_DIR="/root/.m2/repository"
  [ ! -d "$MAVEN_DIR" ] && mkdir -p $MAVEN_DIR

  docker run --rm -it \
    -v $APP_DIR/$APP_NAME:/usr/src/app \
    -v $MAVEN_DIR:/root/.m2/repository \
    -w /usr/src/app maven:3.8.1 mvn clean install -DskipTests=true
}